package com.yzd.learnjava.containers;

import java.util.Iterator;

import com.yzd.learnjava.util.CountingGenerator;
import com.yzd.learnjava.util.Generator;
import com.yzd.learnjava.util.MapData;
import com.yzd.learnjava.util.Pair;
import com.yzd.learnjava.util.Print;
import com.yzd.learnjava.util.RandomGenerator;

public class MapDataTest {
	public static void main(String[] args) {
		Print.print(MapData.map(new Letters(), 11));
		
		Print.print(MapData.map(new CountingGenerator.Character(), new RandomGenerator.String(3), 8));
		
		Print.print(MapData.map(new CountingGenerator.Character(), "Value", 6));
		
		Print.print(MapData.map(new Letters(), new RandomGenerator.String(3)));
		
		Print.print(MapData.map(new Letters(), "Pop"));
	}
}

class Letters implements Generator<Pair<Integer, String>>, Iterable<Integer>{
	private int size = 9;
	private int number = 1 ;
	private char letter = 'A';
	public Pair<Integer, String> next(){
		return new Pair<Integer, String>(number++, "" + letter++);
	}
	
	public Iterator<Integer> iterator(){
		return new Iterator<Integer>() {
			public Integer next() {return number++;}
			public boolean hasNext() {return number < size;}
			public void remove() {throw new UnsupportedOperationException();}
		};
	}
}
